package worldofbearcraft;

import java.util.Scanner;


	public class Game {

		
		public static void main(String[] args) {
			
			Enemy e = new Enemy("Slime", 4, 2, 1);
			Scanner input = new Scanner(System.in); 
			System.out.println("Welcome to World of Bearcraft. What would you like to name your Character?");
			String name = input.next();
			System.out.println("What class would you like to make " +name +"(1)Warrior  (2)Mage  (3)Cleric  (4) Rogue\n\n");
			int calling = input.nextInt();
			
			Player p = null;
			switch (calling)
			{
			case 1:
				p = new Warrior(name);
				break;
			case 2:
				p = new Mage(name);
				break;
			case 3:
				p = new Cleric(name);
				break;
			case 4:
				p = new Rogue(name);
				break;
			}
			p.DisplayInfo();
			e.DisplayInfo();
			System.out.println("OMG, theres a slime.......");
			Fight(p,e);
		}
		
		private static void Fight(Player player, Enemy enemy)
		{		
			boolean _continue = true;
			
			
			
			while (_continue)
			{
				
				
				if (player.getDeath() || enemy.getDeath())
					_continue = false;
				else{
					System.out.println("What are you going to do? \n (1) Fight, (2) Wait, (3) Run, or Quit(4): ");//"game" loop
					Scanner input = new Scanner(System.in);
					int _menuSelection = input.nextInt();
					
					if(_menuSelection == 1)
					{
						if (player.getInitiative() > enemy.getInitiative())
						{
							
							if (!player.getDeath() && !enemy.getDeath())
								player.Attack(enemy);
							if (!player.getDeath() && !enemy.getDeath())
								enemy.Attack(player);
							
						}
						 
						else
						{
							if (!player.getDeath() && !enemy.getDeath())
								enemy.Attack(player);
							if (!player.getDeath() && !enemy.getDeath())
								player.Attack(enemy);
						}
					
					
								
					}
							
					if (_menuSelection == 2)
							{
								System.out.println("You Wait!");
								if (player.getInitiative() < enemy.getInitiative())
									enemy.Attack(player);
								else
								{
								
								_continue = true;}
							}	
					
					if (_menuSelection == 3)
					{
						if (player.getInitiative() < enemy.getInitiative())
							enemy.Attack(player);
						else
						{
						System.out.println("You run away!");
						_continue = false;}
					
					if (_menuSelection == 4)
						{System.out.println("Quitters Never Win!");
						_continue = false;}
					}
				
				}
			}
			//user input: 3 options - fight, wait, run
			
			//enemy will always fight
			
			//exit conditions: win, run, die				
			
		}

	}

